package vns.client.presenter;

import java.util.List;

import vns.client.service.RuleActionServiceAsync;
import vns.client.service.RuleSetServiceAsync;
import vns.client.view.RuleActionUI;
import vns.shared.RuleActionDTO;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.SimpleEventBus;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;

public class RuleActionPresenter implements Presenter {

	@Override
	public void go(HasWidgets container) {
		container.clear();
		container.add(display.asWidget());
		doInitTable();
	}

	public interface Display {
		Button getUpdateButton();

		List<RuleActionDTO> getListRow();

		boolean setListRow(List<RuleActionDTO> listRow);

		Widget asWidget();

		void render();
	}

	private final Display display;
	private final SimpleEventBus eventBus;
	private final RuleSetServiceAsync rpcRuleSet;
	private final RuleActionServiceAsync rpcAction;

	/*
	 * Public method
	 */

	public RuleActionPresenter(RuleActionUI view, SimpleEventBus eventBus,
			RuleActionServiceAsync model1, RuleSetServiceAsync model2) {
		this.display = view;
		this.eventBus = eventBus;
		this.rpcAction = model1;
		this.rpcRuleSet = model2;
		bind();
	}

	/*
	 * Private method
	 */

	private boolean bind() {
		display.getUpdateButton().addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				doUpdate();
			}
		});
		return false;
	}

	private void doInitTable() {
	}

	private void doUpdate() {
	}
}
